package com.ruoyi.web.controller.app;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.wb.domain.WbPlanClassifyYearContent;
import com.ruoyi.wb.service.IWbPlanClassifyYearContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 维保年度类目二级Controller
 * 
 * @author ruoyi
 * @date 2024-11-15
 */
@RestController
@RequestMapping("/system/content")
public class WbAppPlanClassifyYearContentController extends BaseController
{
    @Autowired
    private IWbPlanClassifyYearContentService wbPlanClassifyYearContentService;

    /**
     * 查询维保年度类目二级列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WbPlanClassifyYearContent wbPlanClassifyYearContent)
    {
        startPage();
        List<WbPlanClassifyYearContent> list = wbPlanClassifyYearContentService.selectWbPlanClassifyYearContentList(wbPlanClassifyYearContent);
        return getDataTable(list);
    }

    /**
     * 导出维保年度类目二级列表
     */
    @Log(title = "维保年度类目二级", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WbPlanClassifyYearContent wbPlanClassifyYearContent)
    {
        List<WbPlanClassifyYearContent> list = wbPlanClassifyYearContentService.selectWbPlanClassifyYearContentList(wbPlanClassifyYearContent);
        ExcelUtil<WbPlanClassifyYearContent> util = new ExcelUtil<WbPlanClassifyYearContent>(WbPlanClassifyYearContent.class);
        util.exportExcel(response, list, "维保年度类目二级数据");
    }

    /**
     * 获取维保年度类目二级详细信息
     */
    @GetMapping(value = "/{classifyYearContentId}")
    public AjaxResult getInfo(@PathVariable("classifyYearContentId") Long classifyYearContentId)
    {
        return success(wbPlanClassifyYearContentService.selectWbPlanClassifyYearContentByClassifyYearContentId(classifyYearContentId));
    }

    /**
     * 新增维保年度类目二级
     */
    @Log(title = "维保年度类目二级", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WbPlanClassifyYearContent wbPlanClassifyYearContent)
    {
        return toAjax(wbPlanClassifyYearContentService.insertWbPlanClassifyYearContent(wbPlanClassifyYearContent));
    }

    /**
     * 修改维保年度类目二级
     */
    @Log(title = "维保年度类目二级", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WbPlanClassifyYearContent wbPlanClassifyYearContent)
    {
        return toAjax(wbPlanClassifyYearContentService.updateWbPlanClassifyYearContent(wbPlanClassifyYearContent));
    }

    /**
     * 删除维保年度类目二级
     */
    @Log(title = "维保年度类目二级", businessType = BusinessType.DELETE)
	@DeleteMapping("/{classifyYearContentIds}")
    public AjaxResult remove(@PathVariable Long[] classifyYearContentIds)
    {
        return toAjax(wbPlanClassifyYearContentService.deleteWbPlanClassifyYearContentByClassifyYearContentIds(classifyYearContentIds));
    }
    /**
     * 批量新增维保年度类目二级
     */
    @Log(title = "批量新增维保年度类目二级", businessType = BusinessType.INSERT)
    @PostMapping("/batchAdd")
    public AjaxResult batchAdd(@RequestBody List<WbPlanClassifyYearContent> wbPlanClassifyYearContents)
    {
        return toAjax(wbPlanClassifyYearContentService.batchAdd(wbPlanClassifyYearContents));
    }

}
